package com.shell.customer.chain.service.impl;

import com.shell.bee.base.utils.Encryptor;
import com.shell.customer.chain.service.ChainAcctService;
import com.shell.customer.chain.vo.ChainAcct;
import com.shell.stellar.service.StellarAcctService;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.stellar.sdk.KeyPair;

@Service("chainAcctService")
public class ChainAcctServiceImpl implements ChainAcctService {
	@Autowired
	private StellarAcctService stellarAcctService;

	public ChainAcct open(Set<String> assetCodeSet) throws IOException {
		KeyPair pair = this.stellarAcctService.open(assetCodeSet);
		return new ChainAcct(pair.getAccountId(), Encryptor.encrypt(new String(pair.getSecretSeed())));
	}

	public BigDecimal getAcctBlc(String acctNo, String assetCode) throws IOException {
		return new BigDecimal(this.stellarAcctService.getAcctBlc(acctNo, assetCode));
	}
}